#ifndef HANDLER_H_
#define HANDLER_H_

#include <e32base.h>
#include <nfcserver.h>
#include <ndefmessagelistener.h>
#include <ndefdiscovery.h>
#include <ndefdiscoveryext.h>
#include <ndefmessage.h>

class MNDefMessageObserver;

class CNdefMessageListener : public CBase, public MNdefMessageListener
    {
    
public:
    static CNdefMessageListener * NewL(MNDefMessageObserver & aObserver);
    static CNdefMessageListener * NewLC(MNDefMessageObserver & aObserver);
    ~CNdefMessageListener();
    
public:
    void StartNdefDiscoveryL(CNdefRecord::TNdefRecordTnf aTnf, TDesC8 const & aType);
    void CancelDiscovery();
    void SetForegroundL(TBool aOnForeground);
    
public: // from MNdefMessageListener
    void MessageDetected( CNdefMessage* aMessage );
    
private:
    CNdefMessageListener(MNDefMessageObserver & aObserver) : iObserver(aObserver) {}
    void ConstructL();
    
private:
    void HandleMessageL( CNdefMessage* aMessage );
    
private: // data
    CNdefDiscovery* iNdefDiscovery;
    CNdefDiscoveryExt* iNdefDiscoveryExt;
    
    RNfcServer iNfcServer;
    
    MNDefMessageObserver & iObserver;
    
    };

#endif /* HANDLER_H_ */
